<?php 
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\moblie\controller;
use think\Db;

class Announcement extends Moblie{
    public function getAnnouncement() 
    {
        $where = "1 ";
        if ($_REQUEST['id']) {
            $id = $_REQUEST['id'];
            $where .= "AND a.id = $id";
        }
        // $announcement = M('announcement a');
        $res = Db::name('mob_announcement')->alias('a')->join('xy_sys_users users','users.username = a.name')->field('a.*, users.user_img')->where($where)->order('a.createtime desc')->find();
        echo json_encode($res);

    }

    public function getAnnouncementList  () 
    {
        $index = $_REQUEST['index'];
        $first = $index * 10;

        // $announcement = M('announcement');
        $result = Db::name('mob_announcement')->field("DATE_FORMAT(createtime,'%m-%d %H:%i') createtime, id, name, title")->limit("$first, 10")->order('createtime desc')->select();
        // $sql = $faq_content->getlastsql();
        // file_put_contents('/var/www/html/aaaaa.php',$sql);
        // var_dump($result);exit;
        echo json_encode($result);
    }






}




